package edu.ubb.scrumster.model.model;

import java.sql.Date;
import java.util.List;

public class Sprint implements AbstractModel{
	int id;
	Scrum scrum;
	Date start;
	Date end;
	List<UserStory> userStories;

	public Sprint(Scrum scrum, Date start, Date end) {
		super();
		this.scrum = scrum;
		this.start = start;
		this.end = end;
	}

	public Sprint(int id, Scrum scrum, Date start, Date end) {
		super();
		this.id = id;
		this.scrum = scrum;
		this.start = start;
		this.end = end;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Scrum getScrum() {
		return scrum;
	}

	public void setScrum(Scrum scrum) {
		this.scrum = scrum;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public List<UserStory> getUserStories() {
		return userStories;
	}

	public void setUserStories(List<UserStory> userStories) {
		this.userStories = userStories;
	}

	public String getObjectType(){
		return "Sprint";
	}
	
	public void validate() throws ModelException{
		if (this.start.compareTo(this.end)>0)
				throw new ModelException("Starting date is later than ending date");
	}
}
